<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let users = [
        { name: 'John', age: 20, surname: 'Johnson' },
        { name: 'Pete', age: 18, surname: 'Peterson' },
        { name: 'Ann', age: 19, surname: 'Hathaway' },
        { name: 'Jack', age: 21, surname: 'Jack chen' },
      ];
      function by() {
        return (a, b) => b.age - a.age;
      }
      users.sort(by());
      console.log(users);
    </script>
  </body>
</html>
